package com.klod.data.mapping

import com.klod.data.mapping.NewsTable.autoIncrement
import kotlinx.serialization.Serializable
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.Table

@Serializable
data class UserBean(
    var id:Int=1,
    var name:String,
    var account:String,
    var password:String?,
    var createDate:String ="2025-3-4",
    var type:String ="0",
)

object UserTable : Table("news_user") {

    val id = integer("id").autoIncrement()
    val name = text("name")
    val account = text("account")
    val password = text("password")
    val createDate = text("createDate")
    val type = text("type")

    override val primaryKey = PrimaryKey(id)
}

fun daoToUserModel(dao: ResultRow) =  UserBean(
    id = dao[UserTable.id],
    name = dao[UserTable.name],
    account = dao[UserTable.account],
    password =  dao[UserTable.password],
    createDate = dao[UserTable.createDate],
    type = dao[UserTable.type],

)